<?php


namespace app\api\model\Video;



use think\facade\Db;
use think\Model;

class VideoCateRelationModel extends Model
{
    /**
     * 数据表名
     * @var string
     */
    protected $name = "video_cate_relation";

    /**
     * 获取商品分类
     * @param $where
     * @return mixed
     * @throws
     */
    public static function getVideoCateRelationJoinWhere($where)
    {
        array_push($where, ['vc.is_show','=','1']);
        $field = ['vc.cate_name', 'vc.img as cate_img, vc.sort'];
        $list = Db::name('video_cate_relation as vcr')
            ->join('video_cate as vc', function ($join) {
                $join->on('vcr.cate_id', '=', 'vc.id');
            })
            ->field($field)
            ->where($where)
            ->select()->toArray();
        return $list;
    }

    /**
     * 根据条件查询多条
     * @param $where
     * @return array
     * @throws
     */
    public static function getVideoCateRelationWhereMore($where)
    {
        $list = Db::name('video_cate_relation')->where($where)->select()->toArray();
        return $list;
    }

    /**
     * 统计
     * @param $where
     * @return int
     */
    public static function getVideoCateRelationCountWhere($where)
    {
        $count = Db::name("video_cate_relation")->where($where)->count();
        return $count;
    }
}
